package com.fang.browser;

import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

@Component
public class MyUserDetailsService implements UserDetailsService {

	// 满足对service以及mapper的注入

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		// 注入查找信息,根据姓名和验证码验证。用户所有的权限
		System.err.println(username);

		/*
		 * 同时判断用户是否可登录 String username, String password, boolean enabled,
		 * boolean accountNonExpired, boolean credentialsNonExpired, boolean
		 * accountNonLocked, Collection<? extends GrantedAuthority> authorities
		 */
		return new User(username, "123456", true, true, true, true,
				AuthorityUtils.commaSeparatedStringToAuthorityList("admin"));
	}

}
